/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ControlLayer;
import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;

/**
 *
 * @author Gruppe4
 */
public class CtrlProduct 
{
    /**
     * Creates a new instance of CtrlProduct
     */
    public CtrlProduct()
    {
    
    }
    
    public ArrayList getAllProducts()
    {
        IFDBPro dbProd = new DBProduct();
        ArrayList allProducts = new ArrayList();
        allProducts = dbProd.getAllProducts(false);
        return allProducts;
    }
    
    public Product findProduct(int productId)
    {
        IFDBPro dbprod = new DBProduct();
        return dbprod.findProduct(productId,false);
    }
     
    public void insertProduct(Product pro)
    {
        IFDBPro dbpro = new DBProduct();
        dbpro.insertProduct(pro);
    }
    
    public int updateProduct(int productId, String name)
    {
        IFDBPro dbProd = new DBProduct();
        Product pro = new Product();
        pro.setProductId(productId);
        pro.setName(name);
        return dbProd.updateProduct(pro);  
    }
   
    public void deleteProduct(int productId )
    {
        IFDBPro dbProd = new DBProduct();
        dbProd.deleteProduct(productId);      
    }     
}
